home *** CD-ROM | disk | FTP | other *** search
- doCopyBits( mask, mode, dRect, sRect, dest, source ) /* reversed for pascal-ish-ness */
- BitMap *source, *dest;
- Rect *sRect, *dRect;
- int mode;
- RgnHandle mask;
- {
- int height;
-
- if( !isMyCopy ) {
- isMyCopy = -1;
- height = getMBarHeight() + 8;
- if( dRect->bottom - dRect->top >= height )
- fixCopy( source, dest, sRect, dRect, mode, mask );
- isMyCopy = 0;
- }
- }
-
- installMenuTrap() {
- if( !menuTrapsOn ) {
- installWaitTrap();
- installDelayTrap();
- oldSysMenu = NGetTrapAddress( SysMenuTrapNum, ToolTrap );
- NSetTrapAddress( doSysMenu, SysMenuTrapNum, ToolTrap );
- installPatch( CopyBitsTrapNum, ToolTrap, doCopyBits, filterPatchID );
- sysMenuActed = 0;
- }
- ++menuTrapsOn;
- }
-
- removeMenuTrap() {
- if( sysMenuActed ) {
- removeModalTrap();
- sysMenuActed = 0;
- } else {
- if( menuTrapsOn == 1 ) {
- removePatch( CopyBitsTrapNum, ToolTrap );
- NSetTrapAddress( oldSysMenu, SysMenuTrapNum, ToolTrap );
- removeDelayTrap();
- removeWaitTrap();
- }
- if( menuTrapsOn > 0 ) --menuTrapsOn;
- }
- }
-
- pascal int doSndPlay( chan, sndHdl, async )
- SndChannelPtr chan;
- Handle sndHdl;
- int async;
- {
- return( chan ? SndPlay( chan, sndHdl, async ) : newChannel( sndHdl ) ? noErr : resProblem );
- }
-
- installSndPatch() {
- installPatch( SndPlayTrapNum, ToolTrap, doSndPlay, replacePatchID );
- }
-
- removeSndPatch() {
- removePatch( SndPlayTrapNum, ToolTrap );
- }
-
- pascal doErrSound( which )
- int which;
- {
- if( which ) doSysBeep( 5 );
- }
-
- doSysBeep( count )
- int count;
- {
- installSndPatch();
- SysBeep( count );
- removeSndPatch();
- } asm {
- move #patchContinue,d0
- unlk a6
- rts
- } else {
- err = newChannel( sndHdl ) ? noErr : resProblem;
- asm {
- move #patchReturn,d0
- }
- return( err );
- }
- }
-
- installMenuTrap() {
- if( !menuTrapsOn ) {
- installWaitTrap();
- installDelayTrap();
- oldSysMenu = NGetTrapAddress( SysMenuTrapNum, ToolTrap );
- NSetTrapAddress( doSysMenu, SysMenuTrapNum, ToolTrap );
- oldCopyBits = NGetTrapAddress( CopyBitsTrapNum, ToolTrap );
- NSetTrapAddress( doCopyBits, CopyBitsTrapNum, ToolTrap );
- myCopy = 0;
- sysMenuActed = 0;
- }
- ++menuTrapsOn;
- }
-
- removeMenuTrap() {
- if( sysMenuActed ) {
- removeModalTrap();
- sysMenuActed = 0;
- } else {
- if( menuTrapsOn == 1 ) {
- NSetTrapAddress( oldCopyBits, CopyBitsTrapNum, ToolTrap );
- NSetTrapAddress( oldSysMenu, SysMenuTrapNum, ToolTrap );
- removeDelayTrap();
- removeWaitTrap();
- myCopy = 1;
- }
- if( menuTrapsOn > 0 ) --menuTrapsOn;
- }
- }
-
- doCopyBits( mask, mode, dRect, sRect, dest, source ) /* reversed for pascal-ish-ness */
- BitMap *source, *dest;
- Rect *sRect, *dRect;
- int mode;
- RgnHandle mask;
- {
- int height;
-
- asm {
- movem.l d0-d7/a1-a5,-(sp)
- move.l CurrentA5,a5
- }
- height = getMBarHeight() + 8;
- if( dRect->bottom - dRect->top >= height )
- fixCopy( source, dest, sRect, dRect, mode, mask );
- asm {
- movem.l (sp)+,d0-d7/a1-a5
- unlk a6
- move.l oldCopyBits,a0
- jmp (a0)
- }
- }
- if( !myCopy )
- {
- height = getMBarHeight() + 8;
- if( dRect->bottom - dRect->top >= height )
- fixCopy( source, dest, sRect, dRect, mode, mask );
- }
- main()
- {
- asm {
- bra.s @entry
- count: dc.w #0
- mya5: dc.l #0
- patch: dc.l #0
- original: dc.l #0
- oldpatch: dc.l #0
- savea0: dc.l #0
- regsave: dc.l #0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0
- caller: dc.l #0
- entry: move.l a0,-(sp)
- lea @savea0,a0
- move.l (sp)+,(a0)+
- movem.l d0-d7/a1-a5,(a0)
- lea @caller,a0
- move.l (sp)+,(a0)
- move.l @mya5,a5
- move.l @patch,a0
- jsr (a0)
- move.l @caller,-(sp)
- move.l @savea0,a0
- tst.w d0
- beq.s @replace
- move.l @original,-(sp)
- replace: movem.l @regsave,d0-d7/a1-a5
- rts
- }
-
- main()
- {
- asm {
- bra.s @entry
- count: dc.w #0
- mya5: dc.l #0
- patch: dc.l #0
- original: dc.l #0
- oldpatch: dc.l #0
- savea0: dc.l #0
- regsave: dc.l #0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0,#0
- caller: dc.l #0
- entry: move.l a0,-(sp)
- lea @savea0,a0
- move.l (sp)+,(a0)+
- movem.l d0-d7/a1-a5,(a0)
- lea @caller,a0
- move.l (sp)+,(a0)
- move.l @mya5,a5
- move.l @patch,a0
- jsr (a0)
- move.l @caller,-(sp)
- movem.l @regsave,d0-d7/a1-a5
- move.l @savea0,a0
- rts
- }
- }pascal doErrSound( which )
- int which;
- {
- if( which )
- {
- installSndTrap();
- SysBeep( 1 );
- removeSndTrap();
- }
- }
-
- doSysBeep( count )
- int count;
- {
- /* installSndTrap();
- */ installPatch( SndPlayTrapNum, ToolTrap, doSndPlay, replacePatchID );
- SysBeep( count );
- /* removeSndTrap();
- */ removePatch( SndPlayTrapNum, ToolTrap );
- }installSndTrap()
- {
- if( !soundTrapOn )
- {
- oldSndPlay = NGetTrapAddress( SndPlayTrapNum, ToolTrap );
- NSetTrapAddress( doSndPlay, SndPlayTrapNum, ToolTrap );
- }
- ++soundTrapOn;
- }
-
- removeSndTrap()
- {
- if( soundTrapOn == 1 )
- NSetTrapAddress( oldSndPlay, SndPlayTrapNum, ToolTrap );
- if( soundTrapOn > 0 ) --soundTrapOn;
- }
-
- pascal int doSndPlay( chan, sndHdl, async )
- SndChannelPtr chan;
- Handle sndHdl;
- int async;
- {
- int err;
- asm {
- movem.l d0-d7/a1-a5,-(sp)
- move.l CurrentA5,a5
- }
- if( chan ) asm {
- move.l oldSndPlay,a0
- movem.l (sp)+,d0-d7/a1-a5
- unlk a6
- jmp (a0)
- }
- err = newChannel( sndHdl ) ? noErr : resProblem;
- asm {
- movem.l (sp)+,d0-d7/a1-a5
- }
- return( err );
- }
-